<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除学生信息</title>

    <script type="text/javascript" src="js/jquery-3.5.1.js"></script>

</head>

<body>
    <div id="div" align="center">
        <input id="a" type="text" placeholder="请输入学生id">
        <input id="b" type="button" value="查看" onclick="print()">
        <input id="c" type="button" value="删除" onclick="del()">
        <input id="d" type="button" value="返回" onclick="back()">
    </div>
    <div id="aa" align="center"></div>
</body>

<script>
    function print(){
        $.ajax({
            type:"get",
            url:"/Code/queryStudentServlet",
            data: {"id":$("#a").val()},
            async:true,
            success:function(data){
                var d = eval("("+data+")");
                if(d==null){
                    alert("没有该学生信息");
                }else {
                    $("#aa").html("<table border=\"1px\" width=\"50%\" height=\"100px\" cellspacing=\"0px\" align=\"center\">" +
                        "<tr>" + "<th>学号</th>"
                        + "<th>姓名</th>"
                        + "<th>性别</th>"
                        + "<th>出生日期</th>" +
                        "</tr>" +
                        "<tr align=\"center\">" + "<td>" + d.id + "</td>"
                        + "<td>" + d.sname + "</td>"
                        + "<td>" + d.gender + "</td>"
                        + "<td>" + d.birthday + "</td>" +
                        "</tr>" +
                        "</table>");
                }
            },
        })
    }
    function del() {
        $.ajax({
            type:"get",
            url:"/Code/deleteStudentServlet",
            data:{"id":$("#a").val()},
            async:true,
            success:function(data){
                var d = eval("("+data+")");
                if(d.isExist){
                    alert("学生信息删除成功！！！");
                }else{
                    alert("学生信息删除失败！！！");
                }
                window.location.href="delete.html";
            },
        })
    }
    function back(){
        location.href="view.html";
    }
</script>
</html>